//
//  ChatListTableView.m
//  DogeLegs
//
//  Created by 宋华 on 2017/8/23.
//  Copyright © 2017年 宋华. All rights reserved.
//

#import "ChatListTableView.h"
#import "RecentChat.h"
#import "ChatlistCell.h"

static NSString *ChatlistIdentifier = @"ChatlistCell";

@interface ChatListTableView () {

}


@end

@implementation ChatListTableView


- (id)initWithFrame:(CGRect)frame style:(UITableViewStyle)style
{
    self = [super initWithFrame:frame style:style];
    if (self) {
        [self defaultConfiguration];
    }
    return self;
}
- (void)awakeFromNib {
    [super awakeFromNib];
    [self defaultConfiguration];
}

- (void)defaultConfiguration {
    self.dataSource = self;
    self.delegate = self;
    [self registerNib:[UINib nibWithNibName:ChatlistIdentifier bundle:nil] forCellReuseIdentifier:ChatlistIdentifier];
    self.separatorStyle = UITableViewCellSeparatorStyleNone;
}

#pragma mark - UITableView Delegate & Datasource
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return self.chatLists.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSInteger rowIndex = indexPath.row;
    NSInteger sectionIndex = indexPath.section;
    
    RecentChat   *chatMode = [self.chatLists objectAtIndex:rowIndex];
    
    ChatlistCell  *cell = [tableView dequeueReusableCellWithIdentifier:ChatlistIdentifier forIndexPath:indexPath];
    [cell cellWillDisplay:chatMode];
    
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    return cell;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSInteger sectionIndex = indexPath.section;
    NSInteger rowIndex = indexPath.row;
    
  
    return  80;
}

@end
